// 投诉订单列表
var basePage = require('../../../common/BasePage');
var baseList = require('../../../common/BaseList');
Page({
    behaviors: [basePage, baseList],

    /**
     * 页面的初始数据
     */
    data: {
        reqUrl: '/home/order/complaint/items',
        tabArr: [{
                title: "全部",
                status: 0
            },
            {
                title: "待处理",
                status: 1
            },
            {
                title: "已处理",
                status: 2
            },
            {
                title: "未通过",
                status: 3
            },
        ],
        tabIndex: 0,
        /**端口：user用户端；supplier 商家端 */
        client: "user",
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.data.reqData.client = options.client || "user";
        this.setData({
            client: this.data.reqData.client
        });
        this.req_orders();

    },
    req_orders() {
        this.data.reqData.status = this.data.tabArr[this.data.tabIndex].status;
        this.req_items()
    },
    init_val(val, index, arr) {
        //   val.order.order_product.map(function (pdc) {
        //     pdc.thumb = this.get_thumb(pdc.product_img);
        // });
        val.product.thumb = this.get_thumb(val.product.product_img);
    },
    tab_change(e) {
        // console.log("tab_change", e);
        this.data.tabIndex = e.detail.index;
        this.data.current_page = 0;
        this.req_orders()
    },
    /**查看订单详情 */
    look_order(e) {
        let order = e.detail;
        wx.navigateTo({
            url: '/pages/cls/complaint/Detail?client=' + this.data.client + "&complaint_id=" + order.complaint_id,
        })
    },
    //二次售后
    refund_order(e) {
        console.log("售后",e)
        let order = e.detail;
        let pdc = order.product;
        pdc.wh_id = order.wh_id;
        wx.navigateTo({
            url: "/pages/cls/complaint/Index",
            success: function (obj) {
                //传递产品数据
                obj.eventChannel.emit('pdcData', pdc)
            }
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },


})